package com.jdym.back.controller;


import com.jdym.R;
import com.jdym.back.entity.History;
import com.jdym.back.service.HistoryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 历史贷款表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-09-20
 */
@Api("历史贷款管理")
@CrossOrigin
@RestController
@RequestMapping("/back/history")
public class HistoryController {


    @Autowired
    HistoryService historyService;

//    查询历史贷款
    @GetMapping("/selectHistory/{cobankId}")
    public R getSelectHistory(@PathVariable int cobankId){

        List<History> historyList = historyService.selectHistory(cobankId);
        System.out.println("===historyList===="+historyList);
        return R.ok().data("historyList",historyList).message("查询成功");

    }

//
//    查询历史贷款详情
    @GetMapping("/selectHistoryDetail/{id}")
    public R selectHistoryDetail(@PathVariable int id){

        History historys = historyService.selectHistoryId(id);
        System.out.println("===贷款历史逾期====="+historys);
        return R.ok().data("historys",historys).message("查询成功");

    }


//    关键字去查询银行旗下的企业的历史贷款信息
//    History selectByKey(String key)
    @GetMapping("/selectHistoryKey")
    public R selectHistoryKey(@RequestParam("key") String key){
        History historyKey = historyService.selectByKey(key);
        System.out.println("===贷款历史逾期====="+historyKey);
        return R.ok().data("historyKey",historyKey).message("查询成功");
    }


}
